{extend name="public/base" /}

{block name="content-header"}
<!-- Content Header (Page header) -->
<div class="content-header">
	<div class="container-fluid">
		<div class="row mb-2">
			<div class="col-sm-6">
				<h1 class="m-0 text-dark">数据还原</h1>
			</div><!-- /.col -->
			<div class="col-sm-6">
				<ol class="breadcrumb float-sm-right">
					<li class="breadcrumb-item"><a href="{:Url('index/index')}">首页</a></li>
					<li class="breadcrumb-item"><a href="{:Url('datamanage/index',['type'=>'export'])}">数据备份</a></li>
					<li class="breadcrumb-item active">数据还原</li>
				</ol>
			</div><!-- /.col -->
		</div><!-- /.row -->
	</div><!-- /.container-fluid -->
</div>
<!-- /.content-header -->
{/block}

{block name="content-content"}
<!-- Main content -->
<section class="content">
	<div class="container-fluid">
		<div class="row">
			<div class="col-lg-12">
				<div class="card">
					<div class="card-body p-0">
						<div class="table-responsive">
							<table class="table m-0">
								<thead>
									<tr>
										<th width="200">备份名称</th>
										<th width="80">卷数</th>
										<th width="80">压缩</th>
										<th width="80">数据大小</th>
										<th width="200">备份时间</th>
										<th>状态</th>
										<th width="120">操作</th>
									</tr>
								</thead>
								<tbody>
									{notempty name="list"}
									{volist name="list" id="data"}
									<tr>
										<td>{:date('Ymd-His',$data.time)}</td>
										<td>{$data.part}</td>
										<td>{$data.compress}</td>
										<td>{$data.size|format_bytes}</td>
										<td>{:date('Y-m-d H:i:s',$data.time)}</td>
										<td>-</td>
										<td class="action">
											<a class="db-import" href="{:Url('import?time='.$data['time'])}">还原</a>&nbsp;
											<a class="ajax-get confirm" href="{:Url('del?time='.$data['time'])}">删除</a>
										</td>
									</tr>
									{/volist}
									{else/}
									<td colspan="9" class="text-center"> aOh! 暂时还没有内容! </td>
									{/notempty}
								</tbody>
							</table>
						</div>
						<!-- /.table-responsive -->
					</div>
					<!-- /.card-body -->
					{notempty name="_page"}
					<div class="card-footer clearfix">
						<div class="page">
							{$_page|raw}
						</div>
					</div>
					<!-- /.card-footer -->
					{/notempty}
				</div>
			</div>
		</div>
	</div><!-- /.container-fluid -->
</section>
<!-- /.content -->

<!-- Main content -->
<!-- /.content -->
{/block}

{block name='script'}
<script src="__THEME__/default/view/admin/static/js/common.js?v={:time_version()}"></script>
<script type="text/javascript" charset="utf-8">
//导航高亮
highlight_subnav('{:Url('index',['type'=>'import'])}');
$(".db-import").click(function(){
	var self = this, status = ".";
	$.get(self.href, success, "json");
	window.onbeforeunload = function(){ return "正在还原数据库，请不要关闭！" }
	return false;

	function success(data){
		if(data.code){
			if(data.data.gz){
				data.msg += status;
				if(status.length === 5){
					status = ".";
				} else {
					status += ".";
				}
			}
			$(self).parent().prev().text(data.msg);
			if(data.data.part){
				$.get(self.href, 
						{"part" : data.data.part, "start" : data.data.start}, 
						success, 
						"json"
					 );
			}  else {
				window.onbeforeunload = function(){ return null; }
			}
		} else {
			updateAlert(data.msg,'alert-error');
		}
	}
});
</script>
{/block}
